/**
 *
 */
package picounit.java.file;

import java.io.File;

import picounit.java.collection.List;
import picounit.java.collection.Iterable;

class Directory {
    public Directory(File directory) {
        this.directory = directory;
    }

    public Iterable<File> contents() {
        return contentList();
    }

    private List<File> contentList() {
        List<File> contents = new List<File>();

        for (File file : directory.listFiles()) {
            if (file.isFile()) {
                contents.add(file);
            }

            if (file.isDirectory()) {
                contents.addAll(new Directory(file).contentList());
            }
        }

        return contents;
    }

    private final File directory;
}